package 最长连续子序列;

import java.util.Arrays;
import java.util.Random;

public class Solution {
    /**
     * 代码中的类名、方法名、参数名已经指定，请勿修改，直接返回方法规定的值即可
     * <p>
     * max increasing subsequence
     *
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    static int N = 100010;
    static int[] f = new int[N];

    public int MLS(int[] arr) {
        Arrays.sort(arr);
        int n = arr.length;
        f[0] = 1;
        for (int i = 1; i < n; i++) {
            f[i] = 1;
            if (arr[i - 1] + 1 == arr[i]) {
                f[i] = f[i - 1] + 1;
            } else if (arr[i - 1] == arr[i]) {
                f[i] = f[i - 1];
            }

        }
        int res = 0;
        for (int i = 0; i < n; i++) {
            res = Math.max(res, f[i]);
        }
        return res;
    }
}

